package org.wappumobileapp;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import dataobjects.Category;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

/**
 * DONT USE. Somehow I can't get this to work inside other views. :/
 * @author Minna_2
 *
 */

public class CategoryListActivity extends ListActivity {
	
	Category currentCategory;
	
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		
		setContentView(R.id.categoryListView);
		ListView lv = getListView();
		lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
		lv.setClickable(true);
		
		List<Category> categoryList = Arrays.asList(Category.values());
		
		
		final CategoryArrayAdapter adapter = new CategoryArrayAdapter(
				getApplicationContext(), R.layout.category_listitem, categoryList);
		setListAdapter(adapter);
		
		currentCategory = adapter.getSelectedCategory();
	
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		CategoryArrayAdapter adapter = (CategoryArrayAdapter) getListAdapter();
		currentCategory = adapter.setSelectable(position);
		//String item = (String) getListAdapter().getItem(position);
		//Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
	}
}